home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / BBMAINT1.CMD < prev    next >
OS/2 REXX Batch file  |  1992-03-24  |  20KB  |  759 lines

  1. ;****    TRACE ON        ; Debugging
  2. ;
  3. ; ----- COM-AND BBS UserID maintenance script (User file)
  4. ;    Commenced: 11/90 R.McG
  5. ; -----------------------------------------------------------------------
  6. ;    Purpose:
  7. ;       The script, named BBMAINT1.CMD, produces the main window for
  8. ;    UserID functions of BBMAINT, and implements its functions.  It
  9. ;    is not directly callable itself.
  10. ; -----------------------------------------------------------------------
  11. ;    Usage:
  12. ;       N99 -> Text attribute value (setup by BBMAINT.CMD)
  13. ;       N98 -> BBMAINT Mainline cursor position
  14. ;       N97 -> BBMAINT Mainline cursor position
  15. ;       N96 -> our mainline cursor position
  16. ;       N95 -> our mainline cursor position
  17. ; -----------------------------------------------------------------------
  18. ;
  19. ;    This script is intended ONLY to be used for FCALL
  20. ;
  21.     IF NOT FCALLED
  22.        WOPEN 10,10,13,70 (cont) NOUSEsc
  23.        ATSAY 10,12 (cont) " BBS Users "
  24.        ATSAY 11,12 (cont) " The script: "*"_SCRIPT"
  25.        ATSAY 12,12 (cont) " is not used by itself... it is called through BBMAINT"
  26.        ATSAY 13,26 (cont) " Press any key to continue "
  27.        KEYGET S0        ; Wait for any key
  28.        WCLOSE        ; Close open window
  29.        EXIT         ; Terminate right here
  30.        ENDIF
  31.  
  32.     GOSUB UserFile        ; Invoke function
  33.     FRETURN         ; Return to caller
  34. ; -----------------------------------------------------------------------
  35. ; ----- NoUser:  Inform that there's no USER ID file to modify
  36. ;
  37. NoUser:
  38.     WOPEN 10,10,13,70 (cont) NOUSEsc
  39.     ATSAY 10,12 (cont) " BBS User "
  40.     ATSAY 11,12 (cont) " The file: "*S22&"\BBS-User"
  41.     ATSAY 12,12 (cont) " does not exist.  Please create subdirectories first."
  42.     ATSAY 13,26 (cont) " Press any key to continue "
  43.     ;
  44.     ;    Wait a keypress
  45.     ;
  46.     KEYGET S0        ; Wait for any key
  47.     WCLOSE
  48. NOUSEsc:
  49.     RETURN
  50. ; -----------------------------------------------------------------------
  51. ; ----- Subroutine: UserFile -> Update user ID directory
  52. ;
  53. UserFile:
  54.     GOSUB NewUser        ; Create if not there
  55.     IF NOT ISFILE S22&"\BBS-USER"
  56.        GOSUB NoUser     ; Inform there's no file
  57.        RETURN        ; .. so we can't continue
  58.        ENDIF
  59. ;
  60. ;    Open a window
  61. ;
  62.     WOPEN 0,0 23,79 (defa) User_Esc
  63.     ATSAY 0,2 (defa)   " BBS Users "
  64.     ATSAY 23,25 (defa) " Press ESC to cancel BBMAINT "
  65. ;
  66. ;    Paint the menu
  67. ;
  68. USFI100:
  69.     CLEAR            ; Clear window
  70.     LOCATE 2,2
  71.  
  72.     MESS " 1) Add an ID"
  73.     MESS " 2) Delete an ID"
  74.     MESS " 3) Modify an ID's values"
  75.     MESS " 4) Print User list"
  76.     MESS " 5) View list of IDs"
  77.     MESS "──────────────────────────────────── "
  78.     MESS "Note: Alt-Q to edit a file"
  79.     MESS "      Alt-F for a directory search"
  80.     MESS "      Alt-F10 to shell to DOS"
  81.     MESS " "
  82.     MESS "──────────────────────────────────── "
  83.     MESS " "
  84.     MESS "Select item (carriage return = previous): "
  85.     CURSOR N96,N95        ; Read current cursor
  86. ;
  87. ;    Wait for entry, and interpret
  88. ;
  89. USFI200:
  90.     LOCATE N96 N95        ; Reposition cursor
  91.     KEYGET S0        ; Wait for it
  92.     SWITCH S0        ; Act according to keyget
  93.       CASE "1"
  94.            GOSUB AddID
  95.            ENDCASE
  96.       CASE "2"
  97.            GOSUB DelID
  98.            ENDCASE
  99.       CASE "3"
  100.            GOSUB ModID
  101.            ENDCASE
  102.       CASE "4"
  103.            GOSUB PrnID
  104.            ENDCASE
  105.       CASE "5"
  106.            GOSUB ViewID
  107.            GOTO USFI100    ; Repaint after this
  108.            ENDCASE
  109.       CASE "0d"             ; c/r alone is exit
  110.            WCLOSE        ; Close window...
  111.            RETURN        ; and return to caller
  112.            ENDCASE
  113.       CASE "_NULL"          ; ESC -> Null
  114.            WCLOSE        ; Close window...
  115.            RETURN        ; Leave Main routine
  116.            ENDCASE
  117.       CASE "2100"           ; Alt-F
  118.            MANUAL "0x2100"  ; Perform Dir cmd
  119.            ENDCASE
  120.       CASE "1000"           ; Alt-Q
  121.            MANUAL "0x1000"  ; Edit a file
  122.            ENDCASE
  123.       CASE "7100"           ; Alt-F10
  124.            SHELL
  125.            DWINDOW 1,2,22,78; Reset dwindow after shell
  126.            LEGEND "_LEGEND" ; Redo the legend
  127.            ENDCASE
  128.       DEFAULT        ; None of the above
  129.            SOUND 100,100    ; Bronx cheer
  130.            ENDCASE
  131.       ENDSWITCH
  132.     GOTO USFI200        ; Repaint screen and ask again
  133. ;
  134. ;    End of Users procedure
  135. ;
  136. User_Esc:
  137.     S0 = ""                 ; Fake a nulll entry
  138.     RETURN            ; Leave users routine
  139. ; -----------------------------------------------------------------------
  140. ; ----- AddID:    Add an ID to the User file
  141. ;
  142. AddID:
  143.     SET FLAG(0) OFF     ; Flag for ESCAPE
  144.     WOPEN 10,10,15,70 (cont) ADIDEsc
  145.     ATSAY 10,12 (cont) " BBS User Add "
  146.     ATSAY 11,12 (cont) "Enter the ID to be added: "
  147.     ATSAY 15,26 (cont) " Press ESC to cancel "
  148.     ;
  149.     ;    Wait a keypress
  150.     ;
  151.     LOCATE 11,38
  152.     GET S0 8        ; get ID
  153.     IF FLAG(0) GOTO ADIDEnd ; Exit if ESC hit
  154.     LJ S0            ; Left justify
  155.     UPPER S0        ; ... and upper case
  156.     IF NULL S0 GOTO ADIDEnd ; get out on empty entry
  157.     GOSUB LkpID        ; Lookup ID in User file
  158.     IF FOUND        ; If its there we can't add it
  159.        WCLOSE        ; Close open window
  160.        GOTO ModID_Add    ; Skip if ID found
  161.        ENDIF
  162.     S10 = S0        ; Save ID
  163.     GOTO ADID100        ; And branch around parallel code
  164. ;
  165. ;    Entry from ModID... Nothing to modify
  166. ;
  167. AddID_Mod:
  168.     WOPEN 10,10,15,70 (cont) ADIDEsc
  169.     ATSAY 10,12 (cont) " BBS User Add "
  170.     ATSAY 11,12 (cont) "Enter the ID to be added: "
  171.     ATSAY 11,38 (cont) S0
  172.     ATSAY 15,26 (cont) " Press ESC to cancel "
  173.     S10 = S0        ; Copy it for remainder
  174. ;
  175. ;    Ask for a password
  176. ;
  177. ADID100:
  178.     ATSAY 12,12 (cont) "Enter the password:       "
  179.     LOCATE 12,38
  180.     GET S0 8        ; get resp
  181.     IF FLAG(0) GOTO ADIDEnd ; Exit if ESC hit
  182.     LJ S0            ; Left justify
  183.     UPPER S0        ; ... and upper case
  184.     IF NULL S0        ; Password MUST be filled in
  185.        SOUND 100,100    ; Indicate displeasure
  186.        GOTO ADID100     ; Try again
  187.        ENDIF
  188.     S10(8:15) = S0        ; Save password
  189. ;
  190. ;    Ask for privileged flag
  191. ;
  192. ADID200:
  193.     ATSAY 13,12 (cont) "Priveleged access (y/n):  "
  194.     LOCATE 13,38
  195.     GET S0 1        ; get resp
  196.     IF FLAG(0) GOTO ADIDEnd ; Exit if ESC hit
  197.     IF NULL S0 or NOT FIND "YN" S0(0)
  198.        SOUND 100,100    ; Indicate displeasure
  199.        GOTO ADID200     ; Try again
  200.        ENDIF
  201.     IF FIND "Y" S0(0) S10(16:16) = "P" ; Save priveleged access
  202. ;
  203. ;    Ask for one more look
  204. ;
  205. ADID300:
  206.     ATSAY 14,12 (cont) "OK to add this record?:   "
  207.     LOCATE 14,38
  208.     GET S0 1        ; get resp
  209.     IF FLAG(0) GOTO ADIDEnd ; Exit if ESC hit
  210.     IF NULL S0 or NOT FIND "YN" S0(0)
  211.        SOUND 100,100    ; Indicate displeasure
  212.        GOTO ADID300     ; Try again
  213.        ENDIF
  214.     IF FIND "N" S0(0)
  215.        WCLOSE        ; Close window
  216.        GOTO AddID        ; And try again
  217.        ENDIF
  218. ;
  219. ;    Add comments and write the record
  220. ;
  221.     S10(17:70) = "* Added "*"_DATE"*", at "*"_TIME"
  222.     GOSUB AddUser        ; Write to User file
  223. ;
  224. ;    End of add procedure
  225. ;
  226. ADIDEnd:
  227.     WCLOSE
  228. ADIDEsc:
  229.     SET FLAG(0) ON
  230.     RETURN
  231. ;
  232. ; ----- AddUser:  Add a record to the user file...
  233. ;    .. S10 passes the record to be written
  234. ;
  235. AddUser:
  236.     FOPENO S22&"\BBS-User" TEXT APPEND
  237.     IF NOT SUCCESS        ; Open failed
  238.        S0 = "Error opening: "*S22&"\BBS-User"
  239.        GOSUB Error        ; Report
  240.        RETURN        ; And we're done
  241.        ENDIF
  242.     PRESERVE S10        ; Preserve ^'s and !'s
  243.     WRITE S10        ; Write the record
  244.     WRITE "!^Z"             ; And finish it
  245.     FCLOSEO
  246.     RETURN
  247. ; -----------------------------------------------------------------------
  248. ; ----- LkpID:    Lookup an ID in the BBS-User file
  249. ;    .. S0 passes the ID to be tested
  250. ;    .. S10 returns the record read
  251. ;
  252. LkpID:
  253.     FOPENI S22&"\BBS-User" TEXT
  254.     IF NOT SUCCESS        ; Open failed
  255.        S0 = "Error opening: "*S22&"\BBS-User"
  256.        GOSUB Error        ; Report
  257.        SET FOUND OFF    ; Not found
  258.        RETURN        ; And we're done
  259.        ENDIF
  260. ;
  261. ;    Read loop
  262. ;
  263. LOID100:
  264.     READ S10 80 N0        ; Read a record
  265.     IF EOF GOTO LOID200    ; Skip on EOF
  266.     IF STRCMP S10(0:0) "<" GOTO LOID110
  267.     IF STRCMP S10(0:7) S0(0:7) GOTO LOID300
  268. ;
  269. ;    Record longer than 80 chars
  270. ;
  271. LOID110:
  272.     IF N0 LT 80 GOTO LOID100; If exactly 80 rtnd, c/r wasn't read
  273.     READ S10 80 N0        ; Read remainder of rec
  274.     GOTO LOID110        ; Read until less than 80
  275. ;
  276. ;    We have end-of-file - not found
  277. ;
  278. LOID200:
  279.     SET FOUND OFF        ; Indicate not found
  280.     GOTO LOIDEnd
  281. ;
  282. ;    We have a hit - return found
  283. ;
  284. LOID300:
  285.     SET FOUND ON        ; Indicate found
  286. ;
  287. ;    And exit
  288. ;
  289. LOIDEnd:
  290.     FCLOSEI
  291.     RETURN
  292. ; -----------------------------------------------------------------------
  293. ; ----- DelID:    Delete an ID from User file
  294. ;
  295. DelID:
  296.     SET FLAG(0) OFF     ; Flag for ESCAPE
  297.     WOPEN 10,10,15,70 (cont) DEIDEsc
  298.     ATS